//
//  MyCommentCell.m
//  suRead
//
//  Created by 李 诗洋 on 15/11/19.
//  Copyright © 2015年 bao. All rights reserved.
//

#import "MyCommentCell.h"
#import "M_MyComment.h"

@interface MyCommentCell()

@property (weak, nonatomic) IBOutlet UILabel *nameLable;
@property (weak, nonatomic) IBOutlet UILabel *commentContent;
@property (weak, nonatomic) IBOutlet UILabel *creatTimeLable;

@end
@implementation MyCommentCell
+ (CGFloat)heightWithContent:(NSString *)content_
{
    //个人信息高度 + 底部高度
    CGFloat height_ = 80.0f;
    
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    
    CGFloat contentHeight = [content_ boundingRectWithSize:CGSizeMake(screenWidth - 80.0f - 15.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} context:nil].size.height;
    
    height_ += contentHeight;
    
    return height_;
}

- (void)setCellData:(M_MyComment *)cellData_
{
//    self.userPhoto.image = [UIImage imageNamed:@"icon_personal"];
    self.nameLable.text = cellData_.f_title;
    
    NSString *jsString                 = [NSString stringWithFormat:@"<style type=\"text/css\"> \n"
                                          "span,pre{color: #9e9e9f;font-size: .8rem;}"
                                          "</style> \n"
                                          "%@ \n",cellData_.f_content];
    NSAttributedString * attrStr       = [[NSAttributedString alloc] initWithData:[jsString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    self.commentContent.attributedText = attrStr;
    //self.commentContent.text = cellData_.f_content;
    
    self.creatTimeLable.text = cellData_.f_creat_at;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
